package c.e.b.h.e.q.d;

import android.util.Log;
import c.e.b.h.e.b;
import c.e.b.h.e.k.a;
import c.e.b.h.e.n.d;
import java.io.File;
import java.io.IOException;
import java.util.Map.Entry;

/* compiled from: DefaultCreateReportSpiCall */
public class c extends a implements b {
    public final String f;

    public c(String str, String str2, c.e.b.h.e.n.c cVar, String str3) {
        super(str, str2, cVar, c.e.b.h.e.n.a.POST);
        this.f = str3;
    }

    public boolean a(c.e.b.h.e.q.c.a aVar, boolean z) {
        b bVar = b.a;
        if (z) {
            StringBuilder g;
            c.e.b.h.e.n.b b = b();
            b.d.put("X-CRASHLYTICS-GOOGLE-APP-ID", aVar.b);
            b.d.put("X-CRASHLYTICS-API-CLIENT-TYPE", "android");
            b.d.put("X-CRASHLYTICS-API-CLIENT-VERSION", this.f);
            for (Entry entry : aVar.c.a().entrySet()) {
                b.d.put((String) entry.getKey(), (String) entry.getValue());
            }
            c.e.b.h.e.q.c.c cVar = aVar.c;
            b.c("report[identifier]", cVar.d());
            String str = "application/octet-stream";
            String str2 = " to report ";
            if (cVar.b().length == 1) {
                g = c.b.a.a.a.g("Adding single file ");
                g.append(cVar.c());
                g.append(str2);
                g.append(cVar.d());
                bVar.b(g.toString());
                b.d("report[file]", cVar.c(), str, cVar.f());
            } else {
                int i = 0;
                for (File file : cVar.b()) {
                    StringBuilder g2 = c.b.a.a.a.g("Adding file ");
                    g2.append(file.getName());
                    g2.append(str2);
                    g2.append(cVar.d());
                    bVar.b(g2.toString());
                    g2 = new StringBuilder();
                    g2.append("report[file");
                    g2.append(i);
                    g2.append("]");
                    b.d(g2.toString(), file.getName(), str, file);
                    i++;
                }
            }
            StringBuilder g3 = c.b.a.a.a.g("Sending report to: ");
            g3.append(this.a);
            bVar.b(g3.toString());
            try {
                d a = b.a();
                int i2 = a.a;
                g = new StringBuilder();
                g.append("Create report request ID: ");
                g.append(a.c.c("X-REQUEST-ID"));
                bVar.b(g.toString());
                g3 = new StringBuilder();
                g3.append("Result was: ");
                g3.append(i2);
                bVar.b(g3.toString());
                if (c.e.a.c.a.p(i2) == 0) {
                    return true;
                }
                return false;
            } catch (IOException e) {
                if (bVar.a(6)) {
                    Log.e("FirebaseCrashlytics", "Create report HTTP request failed.", e);
                }
                throw new RuntimeException(e);
            }
        }
        throw new RuntimeException("An invalid data collection token was used.");
    }
}
